package com.itheima.service;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.itheima.mapper.OrderHistoryMapper;
import com.itheima.pojo.OmsOrderOperateHistory;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

@DubboService
public class OrderHistoryImpl implements OrderHistoryApi {
    @Autowired
    private OrderHistoryMapper orderHistoryMapper;

    /**
     * 保存操作记录到表中
     *
     * @param omsOrderOperateHistory
     */
    @Override
    public void save(OmsOrderOperateHistory omsOrderOperateHistory) {
        orderHistoryMapper.insert(omsOrderOperateHistory);
    }

    @Override
    public List<OmsOrderOperateHistory> findByOrderId(Integer id) {
        LambdaQueryWrapper<OmsOrderOperateHistory> wrapper=new LambdaQueryWrapper<>();
        wrapper.eq(OmsOrderOperateHistory::getOrderId,id)
                .orderByDesc(OmsOrderOperateHistory::getCreateTime);
        return orderHistoryMapper.selectList(wrapper);
    }
}
